import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"

// 不是必须加载的组件使用懒加载
// const Icon = () => import("@/views/icon/index")
// const Transfer = () => import("@/views/transfer/transfer")
// const Markdown = () => import("@/views/editor/markdownView")
// const WangeditorView = () => import("@/views/editor/wangeditorView")
const NotFound = () => import("@/views/page404")
// const AddArticle = () => import("@/views/article/addArticle")
// const AddArticleEditor = () => import("@/views/article/addArticleEditor")
// const NavClassify = () => import("@/views/syssetting/navClassify")
// const pagePermissions = () => import("@/views/permissions/pagePermissions")
// const btnPermissions = () => import("@/views/permissions/btnPermissions")
// 1-1.产品管理
const ShoesTable = () => import("@/views/product/shoes/shoesTable")
// 1-2.品牌管理
const BrandsTable = () => import("@/views/product/brands/brandsTable")
// 1-3.类型管理
const TypesTable = () => import("@/views/product/types/typesTable")
// 1-4.类型管理
const ColorsTable = () => import("@/views/product/colors/colorsTable")
// 1-5.尺寸管理
const SizesTable = () => import("@/views/product/sizes/sizesTable")
// 2 订单管理
const OrderTable = () => import("@/views/order/orderTable")
// 3 用户管理
const UserTable = () => import("@/views/user/userTable")
// 4-1 业绩报表
const ReportPerformance = () => import("@/views/report/reportPerformance")
// 4-2 营销报表
const ReportMarketing = () => import("@/views/report/reportMarketing")
// 4-3 流量报表
const ReportFlow = () => import("@/views/report/reportFlow")
// 5-1 合作链接
const FriendLinksTable = () => import("@/views/corporate/flink/friendLinksTable")
// 5-2 广告列表
const AdsList = () => import("@/views/corporate/ads/adsTable")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  { path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "",
    hidden: true,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: routeName.home,
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component: HomeMain,
        children: []
      }
    ]
  },
  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  }
]

let addRouter = [
  // {
  //   path: "/",
  //   iconCls: "el-icon-tickets", // 图标样式class
  //   name: routeName.article,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/addArticle",
  //       iconCls: "el-icon-edit-outline", // 图标样式class
  //       name: routeName.publishArticle,
  //       component: AddArticle,
  //       children: []
  //     },
  //     {
  //       path: "/addArticleEditor",
  //       iconCls: "el-icon-edit-outline", // 图标样式class
  //       name: routeName.publishArticleEditor,
  //       // hidden: true,
  //       component: AddArticleEditor,
  //       children: []
  //     }
  //   ]
  // },
  // {
  //   path: "/",
  //   iconCls: "fa fa-paw", // 图标样式class
  //   name: routeName.icon,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/icon",
  //       iconCls: "fa fa-life-ring", // 图标样式class
  //       name: routeName.builtInIcon,
  //       component: Icon,
  //       children: []
  //     }
  //   ]
  // },
  // {
  //   path: "/",
  //   iconCls: "fa fa-exchange", // 图标样式class
  //   name: routeName.shuttleBox,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/transfer",
  //       iconCls: "fa fa-sign-in", // 图标样式class
  //       name: routeName.demoShuttle,
  //       component: Transfer,
  //       children: []
  //     }
  //   ]
  // },
  // {
  //   path: "/",
  //   iconCls: "fa fa-universal-access", // 图标样式class
  //   name: routeName.permissions,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/pagePermissions",
  //       iconCls: "fa fa-expeditedssl", // 图标样式class
  //       name: routeName.pageControl,
  //       component: pagePermissions,
  //       children: []
  //     },
  //     {
  //       path: "/btnPermissions",
  //       iconCls: "fa fa-toggle-on", // 图标样式class
  //       name: routeName.btnControl,
  //       component: btnPermissions,
  //       children: []
  //     }
  //   ]
  // },
  // {
  //   path: "/",
  //   iconCls: "el-icon-edit", // 图标样式class
  //   name: routeName.editor,
  //   component: Layout,
  //   meta: {role: ["superAdmin", "admin"]},
  //   children: [
  //     {
  //       path: "/markdown",
  //       iconCls: "fa fa-file-code-o", // 图标样式class
  //       name: routeName.markdown,
  //       component: Markdown,
  //       children: []
  //     },
  //     {
  //       path: "/wangeditor",
  //       iconCls: "fa fa-file-code-o", // 图标样式class
  //       name: routeName.wangeditor,
  //       component: WangeditorView,
  //       children: []
  //     }
  //   ]
  // },
  // {
  //   path: "/",
  //   iconCls: "el-icon-setting", // 图标样式class
  //   name: routeName.systemSettings,
  //   component: Layout,
  //   meta: {role: ["superAdmin"]},
  //   children: [
  //     {
  //       path: "/navClassifies",
  //       iconCls: "el-icon-menu", // 图标样式class
  //       name: routeName.navMenu,
  //       component: NavClassify,
  //       children: []
  //     }
  //   ]
  // },
  {
    // 1.商品管理
    path: "/",
    iconCls: "fa fa-bars",
    name: routeName.productManage,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        // 1-1.产品列表
        path: "/shoesList",
        iconCls: "el-icon-s-cooperation",
        name: routeName.shoesList,
        component: ShoesTable,
        children: []
      },
      {
        // 1-2.品牌管理
        path: "/brandsList",
        iconCls: "fa fa-suitcase",
        name: routeName.brandsList,
        component: BrandsTable,
        children: []
      },
      {
        // 1-3.类型管理
        path: "/typesList",
        iconCls: "fa fa-archive",
        name: routeName.typesList,
        component: TypesTable,
        children: []
      },
      {
        // 1-4.颜色管理
        path: "/colorsList",
        iconCls: "fa fa-adjust",
        name: routeName.colorsList,
        component: ColorsTable,
        children: []
      },
      {
        // 1-5.鞋码管理
        path: "/sizesList",
        iconCls: "el-icon-notebook-2",
        name: routeName.sizesList,
        component: SizesTable,
        children: []
      }
    ]
  },
  {
    // 2.订单管理
    path: "/",
    iconCls: "el-icon-s-order",
    name: routeName.orderManage,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        // 2-1.待发货订单
        path: "/backlogOrder",
        iconCls: "el-icon-sold-out",
        name: routeName.backlogOrder,
        component: OrderTable,
        children: []
      },
      {
        // 2-2.运输中订单
        path: "/transitOrder",
        iconCls: "el-icon-box",
        name: routeName.transitOrder,
        component: OrderTable,
        children: []
      },
      {
        // 2-3.交易成功的订单
        path: "/completeOrder",
        iconCls: "el-icon-present",
        name: routeName.completeOrder,
        component: OrderTable,
        children: []
      },
      {
        // 2-4 申请退货订单
        path: "/applyingReturnOrder",
        iconCls: "el-icon-sell",
        name: routeName.applyingReturnOrder,
        component: OrderTable,
        children: []
      },
      {
        // 2-5 已退货订单
        path: "/returnedOrder",
        iconCls: "el-icon-shopping-bag-1",
        name: routeName.returnedOrder,
        component: OrderTable,
        children: []
      },
      {
        // 2-6 已取消订单
        path: "/cancelledOrder",
        iconCls: "el-icon-shopping-bag-2",
        name: routeName.cancelledOrder,
        component: OrderTable,
        children: []
      }
    ]
  },
  {
    // 3.用户管理
    path: "/",
    iconCls: "fa fa-address-book",
    name: routeName.userManage,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        // 3-1.用户列表
        path: "/userList",
        iconCls: "fa fa-address-card",
        name: routeName.userList,
        component: UserTable,
        children: []
      }
    ]
  },
  {
    // 4.报表管理
    path: "/",
    iconCls: "fa fa-line-chart",
    name: routeName.reportView,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        // 4-1.业绩报表
        path: "/reportPerformance",
        iconCls: "fa fa-pie-chart",
        name: routeName.reportPerformance,
        component: ReportPerformance,
        children: []
      },
      {
        // 4-2.营销报表
        path: "/reportMarketing",
        iconCls: "el-icon-s-marketing",
        name: routeName.reportMarketing,
        component: ReportMarketing,
        children: []
      },
      {
        // 4-3.流量报表
        path: "/reportFlow",
        iconCls: "fa fa-area-chart",
        name: routeName.reportFlow,
        component: ReportFlow,
        children: []
      }
    ]
  },
  {
    // 5.企宣管理
    path: "/",
    iconCls: "el-icon-s-check",
    name: routeName.corporateManage,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        // 5-1.合作链接
        path: "/flinksList",
        iconCls: "el-icon-share",
        name: routeName.friendLinksList,
        component: FriendLinksTable,
        children: []
      },
      {
        // 5-2.广告列表
        path: "/adsList",
        iconCls: "el-icon-s-finance",
        name: routeName.adsList,
        component: AdsList,
        children: []
      }
    ]
  },
  { path: "*",
    redirect: "/404",
    hidden: true,
    children: []
  }

]
export default new Router({
  routes: defaultRouter
})
export {defaultRouter, addRouter}
